package com.chesnutconsulting.reports;

import org.springframework.mobile.device.Device;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/sql-reports-entry")
public class ReportEntryController {

	@RequestMapping(method = RequestMethod.GET)
	public ModelAndView welcome(Device device) {

		if (device.isMobile()) {
			ModelAndView model = new ModelAndView("reportSelectionMobile");
			model.addObject("uiConfig",
					ReportsInitializer.getReportWidgetTypeMap());
			model.addObject("menu", ReportsInitializer.getRootReportCategory().getReportCategories().get(0) );
			return model;
		} else {
			ModelAndView model = new ModelAndView("reportSelection");
			model.addObject(ReportsInitializer.getReportWidgetTypeMap());
			model.addObject("uiConfig",
					ReportsInitializer.getReportWidgetTypeMap());
			model.addObject("menu", ReportsInitializer.getRootReportCategory().getReportCategories().get(0) );
			return model;
		}

	}

}